package com.hhl.test;

import com.alibaba.fastjson.JSONObject;
import com.hhl.menu.BaseButton;
import com.hhl.menu.ClickButton;
import com.hhl.menu.ComlexButton;
import com.hhl.menu.Menu;
import com.hhl.menu.ViewButton;
import com.hhl.util.HttpRequestUtil;
import com.hhl.util.WXURLUtil;
import com.hhl.util.WechatAccessToken;


/**
 * 大坪病案打印
 * 说明：<br>
 * <h1>创 建 人: hehailong   <br></h1>
 * 创建日期: 2017-11-13 下午4:43:51<br>
 * 需要的jar包:
 */
public class menutest {

	public static void main(String[] args) {
		
		ViewButton vb1_1 = new ViewButton();
		vb1_1.setName("个人码云");
		vb1_1.setType("view");
		vb1_1.setUrl("https://gitee.com/hhlhhl/");
		
		ViewButton vb1_2 = new ViewButton();
		vb1_2.setName("个人CSDN");
		vb1_2.setType("view");
		vb1_2.setUrl("https://blog.csdn.net/qq_25293281");
		
		ComlexButton menu1 = new ComlexButton();
		menu1.setName("个人博客");
		menu1.setSub_button(new BaseButton[]{vb1_1,vb1_2});
		
		ComlexButton appMenu = new ComlexButton();
		ViewButton webSetApp = new ViewButton();
		webSetApp.setName("步骤详情");
		webSetApp.setType("view");
		webSetApp.setUrl("https://mp.weixin.qq.com/wiki");
		
		ViewButton webSetApp1 = new ViewButton();
		webSetApp1.setName("申请测试号");
		webSetApp1.setType("view");
		webSetApp1.setUrl("https://mp.weixin.qq.com/debug/cgi-bin/sandboxinfo?action=showinfo&t=sandbox/index");
		
		appMenu.setName("开发教程");
		appMenu.setSub_button(new BaseButton[]{webSetApp,webSetApp1});
		
		
		ComlexButton a = new ComlexButton();
		ClickButton aa = new ClickButton();
		aa.setKey("GYWM");
		aa.setName("关于我们");
		aa.setType("click");
		
		ViewButton aa1 = new ViewButton();
		aa1.setName("联系我们");
		aa1.setType("view");
		aa1.setUrl("http://wpa.qq.com/msgrd?v=3&uin=1414454875&site=oicqzone.com&menu=yes");
		
		ClickButton aa2 = new ClickButton();
		aa2.setKey("KEY_MZ_KNOW");
		aa2.setName("测试图文");
		aa2.setType("click");
		
		ClickButton aa3 = new ClickButton();
		aa3.setKey("KEY_RY_KNOW");
		aa3.setName("测试文本");
		aa3.setType("click");
		
		a.setName("联系我们");
		a.setSub_button(new BaseButton[]{aa,aa1,aa2,aa3});
		
		Menu menu = new Menu();
		menu.setButton(new BaseButton[]{menu1,appMenu,a});
		
		String btnJson = JSONObject.toJSONString(menu);
		
		System.out.println(btnJson);
		
		
		String token = WechatAccessToken.getAccessToken("wx289adfd6df38b03d", "ff1f9a6468e49743affaebd5437405f2").getToken();
		System.out.println(JSONObject.toJSONString(menu));
		
		
		JSONObject bbb = HttpRequestUtil.httpRequest(WXURLUtil.MENU_URL.replace("ACCESS_TOKEN", token), "POST", JSONObject.toJSONString(menu));
		System.out.println(JSONObject.toJSONString(bbb));
		
	}
	
}
